package cn.icanci.loopstack.bic.sample.service.impl;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import cn.hutool.json.JSONUtil;
import cn.icanci.loopstack.bic.sample.infrastructure.GoodsClient;
import cn.icanci.loopstack.bic.sample.service.OrderService;
import cn.icanci.loopstack.bic.sdk.burying.LoggerBuryingUtils;
import cn.icanci.loopstack.bic.sdk.burying.aop.SysLog;

/**
 * @author icanci
 * @since 1.0 Created in 2023/09/27 16:29
 */
@Service
public class OrderServiceImpl implements OrderService {

    @Resource
    private GoodsClient goodsClient;

    @SysLog
    @Override
    public Object createOrder(String traceId, Date date) {
        Map<String, Object> map = new HashMap<>();
        map.put("hhh", "hhh");
        map.put("xxx", "xxx");
        map.put("createOrder", "createOrder");
        map.put("date", date);
        LoggerBuryingUtils.info(traceId, "[OrderService][createOrder] request: " + JSONUtil.toJsonStr(map));
        Object goods = goodsClient.createGoods(map);
        LoggerBuryingUtils.info(traceId, "[OrderService][createOrder] response: " + JSONUtil.toJsonStr(goods));
        return map;
    }

    @SysLog
    @Override
    public Object searchOrder(String traceId, Date date) {
        Map<String, Object> map = new HashMap<>();
        map.put("hhh", "hhh");
        map.put("xxx", "xxx");
        map.put("searchOrder", "searchOrder");
        map.put("date", date);
        LoggerBuryingUtils.info(traceId, "[OrderService][createOrder] request: " + JSONUtil.toJsonStr(map));
        Object goods = goodsClient.searchGoods(map);
        LoggerBuryingUtils.info(traceId, "[OrderService][createOrder] response: " + JSONUtil.toJsonStr(goods));
        return map;
    }
}
